import {View, Button, Text, Image, ScrollView, Radio} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';
import * as T from '../types';
import './taskList.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';
import moneyImage from '@/assets/image/index/money.png';
// import noList from '@/pages/package-B/myGiftPack/img/noList.png';

type ITopProps = T.IProps & T.ITopProps;
//@ts-ignore
@connect<Partial<ITopProps>, T.ITopState>(store2Props, actions)
export default class Info extends Component<Partial<ITopProps>, T.ITopState> {
  constructor(props: ITopProps) {
    super(props);
    this.state = {};
  }

  render() {
    let {
      actions: {action},
      main: {taskList},
    } = this.props;

    return (
      <View className="taskList">
        {taskList.map((e) => (
          <View className="task" key={e.taskId}>
            <Image className="task-logo" src={e.taskLogo} />
            <View
              style={{
                maxWidth: '50%',
              }}
            >
              <Text className="task-title">
                {e.taskName}
                {`(${e.completedTimes}/${e.sumTimes})`}
              </Text>
              <Text className="task-subTitle">{e.taskDesc}</Text>
              <View className="task-awardBox">
                <Image src={moneyImage} className="task-awardBox-awardLogo" />+{e.taskActivation}
              </View>
            </View>
            <View
              className={`task-Button ${e.completedTimes !== e.sumTimes ? '' : 'task-Button--disable'}`}
              onClick={() => {
                if (e.completedTimes !== e.sumTimes) {
                  this.props.actions.action.goFinish(e);
                }
              }}
            >
              {e.completedTimes !== e.sumTimes ? '去完成' : '明天再来'}
            </View>
          </View>
        ))}
        {taskList.length <= 0 && (
          <View className="taskList-noList">
            {/* <Image src={noList} style={{width: '394rpx', height: '270rpx'}} /> */}
            啊哦，暂无任务～
          </View>
        )}
      </View>
    );
  }
}
